package com.company;

/*public class Main{
    int puppyAge;
    public Main(String name){
        // 这个构造器仅有一个参数：name
        System.out.println("小狗的名字是 : " + name );
    }

    public void setAge( int age ){
        puppyAge = age;
    }

    public int getAge( ){
        System.out.println("小狗的年龄为 : " + puppyAge );
        return puppyAge;
    }

    public static void main(String []args){
        Main mydog=new Main("tommy");
        mydog.setAge(2);
        mydog.getAge();
        System.out.println("变量值："+mydog.puppyAge);

    }
}*/

/*public class Main{
    public static void main(String[] args){
        //int i1 = 123;
        //byte b = (byte)i1;//强制类型转换为byte
        int a=(1+3)+(3+2)*2;
        int [] numbers = {10, 20, 30, 40, 50};
        for(int x:numbers){
            System.out.print(x);
            System.out.println(",");
        }
        System.out.println("int强制类型转换为byte后的值等于"+a);
    }

}*/
//99乘法表
/*public class Main {
    public static void main(String args[]) {
        for(int i=1;i<=9;i++){
            for(int j=1;j<=i;j++){
                System.out.print(j+"*"+i+"="+i*j+" ");
            }
            System.out.println();
        }
    }
}*/

//Switch语句
/*import java.util.*;
public class Main {
    public static void main(String args[]){
        //char grade = args[0].charAt(0);
       // char grade ;
        Scanner in = new Scanner(System.in);
        System.out.print("输入：");
        String s = in.nextLine();
       // grade=in.next();
        switch(s)
        {
            case "优秀" :
                System.out.println("优秀");
                break;
            case "hh" :
            case "lh" :
                System.out.println("良好");
                break;
            case "j" :
                System.out.println("及格");
            case "kk" :
                System.out.println("你需要再努力努力");
                break;
            default :
                System.out.println("未知等级");
        }
        System.out.println("你的等级是 " + s);
    }
}*/

//String类
/*public class Main{
    public static void main(String args[]){
        char[] helloArray = { 'r', 'u', 'n', 'o', 'o', 'b'};
        String helloString = new String(helloArray);
        System.out.println( helloString );
    }
}*/

//String length()、size()区别
/*import java.util.*;
public class Main{
    public static void main(String[] args) {
        String []list={"ma","cao","yuan"};
        String a="macaoyuan";
        System.out.println(list.length);
        System.out.println(a.length());
        List array=new ArrayList();
        array.add(a);
        //System.out.println("\n");
        System.out.println(array.size());
    }
}*/

//实现数组和字符串的转换处理
/*public class Main {
    public static void main(String args[]) {
        String str = "helloworld";
        char[] data = str.toCharArray();// 将字符串转为数组
        for (int x = 0; x < data.length; x++) {
            System.out.print(data[x] + "  ");
            data[x] -= 32;
            System.out.print(data[x] + "  ");
        }
        System.out.println(new String(data));
        System.out.println(data);//?为什么
    }
}*/

/*import java.util.Scanner;

//猜字符小游戏
public class Main {
    private static Scanner scan;
    // 主方法
    public static void main(String[] args) {
        scan = new Scanner(System.in);
        char[] chs = generate();
        System.out.println(chs);
        int count = 0; // 猜错的次数
        while (true) { // 自造死循环
            System.out.println("猜吧!");
            String str = scan.next().toUpperCase(); // 获取用户输入的字符串
            if (str.equals("EXIT")) { // 判断字符串内容相等
                System.out.println("下次再来吧!");
                break;
            }
            char[] input = str.toCharArray(); // 将字符串转换为字符数组
            int[] result = check(chs, input);
            if (result[0] == chs.length) { // 对
                int score = 100 * chs.length - 10 * count;
                System.out.println("恭喜你，猜对了!得分为:" + score);
                break;
            } else {
                count++;
                System.out.println("字符对个数为:" + result[1] + "，位置对个数为:" + result[0]);
            }
        }
    }
    // 生成随机字符数组chs
    public static char[] generate() {
        char[] chs = new char[5];
        char[] letters = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
                'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
                'W', 'X', 'Y', 'Z' };
        boolean[] flags = new boolean[letters.length];
        for (int i = 0; i < chs.length; i++) {
            int index;
            do {
                index = (int) (Math.random() * letters.length);
            } while (flags[index] == true);
            chs[i] = letters[index];
            flags[index] = true;
        }
        // i=0 index=0 chs[0]='A' flags[0]=true
        // i=1 index=25 chs[1]='Z' flags[25]=true
        // i=2 index=0/25/0/25/1 chs[2]='B' flags[1]=true
        return chs;
    }

    // 对比:随机字符数组chs与用户输入的字符数组input
    public static int[] check(char[] chs, char[] input) {
        int[] result = new int[2]; // (0,0)
        for (int i = 0; i < chs.length; i++) {
            for (int j = 0; j < input.length; j++) {
                if (chs[i] == input[j]) {
                    result[1]++;
                    if (i == j) {
                        result[0]++;
                    }
                    break;
                }
            }
        }
        return result;
    }
}*/
//获取当前日期
import java.util.Date;

public class Main {
    public static void main(String args[]) {
        // 初始化 Date 对象
        Date date = new Date();

        // 使用 toString() 函数显示日期时间
        System.out.println(date.toString());
        System.out.printf("年-月-日格式：%tF%n",date);

    }
}

